<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>OpenLoong Dynamics Control: foot_placement.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">OpenLoong Dynamics Control
   &#160;<span id="projectnumber">v0.1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_692f640cc74363071c5c0e14282656e9.html">algorithm</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">foot_placement.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/*</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment">This is part of OpenLoong Dynamics Control, an open project for the control of biped robot,</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment">Copyright (C) 2024 Humanoid Robot (Shanghai) Co., Ltd, under Apache 2.0.</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment">Feel free to use in any purpose, and cite OpenLoong-Dynamics-Control in any style, to contribute to the advancement of the community.</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> &lt;https://gitee.com/panda_23/openloong-dyn-control.git&gt;</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> &lt;web@openloong.org.cn&gt;</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment">*/</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160; </div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160; </div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor">#include &lt;Eigen/Dense&gt;</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &quot;data_bus.h&quot;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160; </div>
<div class="line"><a name="l00018"></a><span class="lineno"><a class="line" href="classFootPlacement.html">   18</a></span>&#160;<span class="keyword">class </span><a class="code" href="classFootPlacement.html">FootPlacement</a> {</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00020"></a><span class="lineno"><a class="line" href="classFootPlacement.html#ae58f1f2ea1c2d690d10f4c7b7b0c67d0">   20</a></span>&#160;    <span class="keywordtype">double</span> <a class="code" href="classFootPlacement.html#ae58f1f2ea1c2d690d10f4c7b7b0c67d0">kp_vx</a>{0},                                         </div>
<div class="line"><a name="l00021"></a><span class="lineno"><a class="line" href="classFootPlacement.html#a9e1f6a5e58ce202d031a17be6652ce20">   21</a></span>&#160;        <a class="code" href="classFootPlacement.html#a9e1f6a5e58ce202d031a17be6652ce20">kp_vy</a>{0},                                            </div>
<div class="line"><a name="l00022"></a><span class="lineno"><a class="line" href="classFootPlacement.html#ad375e1c3c0dfa0c73e13372b092a0738">   22</a></span>&#160;        <a class="code" href="classFootPlacement.html#ad375e1c3c0dfa0c73e13372b092a0738">kp_wz</a>{0};                                            </div>
<div class="line"><a name="l00023"></a><span class="lineno"><a class="line" href="classFootPlacement.html#ab5b95a95c66387cf179dc54179d956a0">   23</a></span>&#160;    <span class="keywordtype">double</span> <a class="code" href="classFootPlacement.html#ab5b95a95c66387cf179dc54179d956a0">legLength</a>{1};                                     </div>
<div class="line"><a name="l00024"></a><span class="lineno"><a class="line" href="classFootPlacement.html#ab42c8e066a9f7d1997ca7780af64c932">   24</a></span>&#160;    <span class="keywordtype">double</span> <a class="code" href="classFootPlacement.html#ab42c8e066a9f7d1997ca7780af64c932">stepHeight</a>{0.1};                                  </div>
<div class="line"><a name="l00025"></a><span class="lineno"><a class="line" href="classFootPlacement.html#a7efde20d6d1358c936a6d97b98993413">   25</a></span>&#160;    <span class="keywordtype">double</span> <a class="code" href="classFootPlacement.html#a7efde20d6d1358c936a6d97b98993413">phi</a>{0};                                           </div>
<div class="line"><a name="l00026"></a><span class="lineno"><a class="line" href="classFootPlacement.html#a3aa4e1578da7623da69007b491e8765b">   26</a></span>&#160;    <span class="keywordtype">double</span> <a class="code" href="classFootPlacement.html#a3aa4e1578da7623da69007b491e8765b">tSwing</a>{0.4};                                      </div>
<div class="line"><a name="l00027"></a><span class="lineno"><a class="line" href="classFootPlacement.html#a2cdda47344b6685852f8346ec351f8c1">   27</a></span>&#160;    Eigen::Vector3d posStart_W, posDes_W, hipPos_W, <a class="code" href="classFootPlacement.html#a2cdda47344b6685852f8346ec351f8c1">STPos_W</a>; </div>
<div class="line"><a name="l00028"></a><span class="lineno"><a class="line" href="classFootPlacement.html#a2c65ca56953f4f104ff55200656cffee">   28</a></span>&#160;    Eigen::Vector3d desV_W, <a class="code" href="classFootPlacement.html#a2c65ca56953f4f104ff55200656cffee">curV_W</a>;                          </div>
<div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="classFootPlacement.html#a65426884931e20e457a72ebd2885ca91">   29</a></span>&#160;    <span class="keywordtype">double</span> <a class="code" href="classFootPlacement.html#a65426884931e20e457a72ebd2885ca91">desWz_W</a>;                                          </div>
<div class="line"><a name="l00030"></a><span class="lineno"><a class="line" href="classFootPlacement.html#aa56a97026449da92c7bb7e65374a26bc">   30</a></span>&#160;    Eigen::Vector3d <a class="code" href="classFootPlacement.html#aa56a97026449da92c7bb7e65374a26bc">base_pos</a>;                                </div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;    </div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;    <span class="keywordtype">double</span> <a class="code" href="classFootPlacement.html#ae2211312c822d1d49d61553fbf692feb">Trajectory</a>(<span class="keywordtype">double</span> phase, <span class="keywordtype">double</span> des1, <span class="keywordtype">double</span> des2);</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classFootPlacement.html#a44ed054253f62f43df8b23f60694d600">getSwingPos</a>();</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classFootPlacement.html#abefe39cf532cd6ee56094fd96b9aead1">dataBusRead</a>(<a class="code" href="structDataBus.html">DataBus</a> &amp;robotState);</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classFootPlacement.html#a833b5bb6ef5578bfed4d8d50c9786fa7">dataBusWrite</a>(<a class="code" href="structDataBus.html">DataBus</a> &amp;robotState);</div>
<div class="line"><a name="l00059"></a><span class="lineno"><a class="line" href="classFootPlacement.html#a8bc8c4f7d3ffc58d244cfc3935e31c13">   59</a></span>&#160;    <a class="code" href="structDataBus.html#a0dcb8a4552bb6b37259a61d601cd7d7e">DataBus::LegState</a> <a class="code" href="classFootPlacement.html#a8bc8c4f7d3ffc58d244cfc3935e31c13">legState</a>; </div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;    <span class="keywordtype">double</span> pDesCur[3]{0}; </div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;    <span class="keywordtype">double</span> yawCur;        </div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;    <span class="keywordtype">double</span> theta0;        </div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;    <span class="keywordtype">double</span> omegaZ_W;      </div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;    <span class="keywordtype">double</span> hip_width;     </div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;};</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160; </div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aclassFootPlacement_html_ab5b95a95c66387cf179dc54179d956a0"><div class="ttname"><a href="classFootPlacement.html#ab5b95a95c66387cf179dc54179d956a0">FootPlacement::legLength</a></div><div class="ttdeci">double legLength</div><div class="ttdoc">length of the leg</div><div class="ttdef"><b>Definition:</b> <a href="foot__placement_8h_source.html#l00023">foot_placement.h:23</a></div></div>
<div class="ttc" id="aclassFootPlacement_html"><div class="ttname"><a href="classFootPlacement.html">FootPlacement</a></div><div class="ttdoc">This class is used to generate swing leg trajectory.</div><div class="ttdef"><b>Definition:</b> <a href="foot__placement_8h_source.html#l00018">foot_placement.h:18</a></div></div>
<div class="ttc" id="aclassFootPlacement_html_a2cdda47344b6685852f8346ec351f8c1"><div class="ttname"><a href="classFootPlacement.html#a2cdda47344b6685852f8346ec351f8c1">FootPlacement::STPos_W</a></div><div class="ttdeci">Eigen::Vector3d STPos_W</div><div class="ttdoc">step position in world coordinate</div><div class="ttdef"><b>Definition:</b> <a href="foot__placement_8h_source.html#l00027">foot_placement.h:27</a></div></div>
<div class="ttc" id="aclassFootPlacement_html_aa56a97026449da92c7bb7e65374a26bc"><div class="ttname"><a href="classFootPlacement.html#aa56a97026449da92c7bb7e65374a26bc">FootPlacement::base_pos</a></div><div class="ttdeci">Eigen::Vector3d base_pos</div><div class="ttdoc">current position of robot base in world coordinate</div><div class="ttdef"><b>Definition:</b> <a href="foot__placement_8h_source.html#l00030">foot_placement.h:30</a></div></div>
<div class="ttc" id="aclassFootPlacement_html_a2c65ca56953f4f104ff55200656cffee"><div class="ttname"><a href="classFootPlacement.html#a2c65ca56953f4f104ff55200656cffee">FootPlacement::curV_W</a></div><div class="ttdeci">Eigen::Vector3d curV_W</div><div class="ttdoc">desired and current body velocity in world coordinate</div><div class="ttdef"><b>Definition:</b> <a href="foot__placement_8h_source.html#l00028">foot_placement.h:28</a></div></div>
<div class="ttc" id="aclassFootPlacement_html_ad375e1c3c0dfa0c73e13372b092a0738"><div class="ttname"><a href="classFootPlacement.html#ad375e1c3c0dfa0c73e13372b092a0738">FootPlacement::kp_wz</a></div><div class="ttdeci">double kp_wz</div><div class="ttdoc">Catersian swing foot position control gain in z-axis.</div><div class="ttdef"><b>Definition:</b> <a href="foot__placement_8h_source.html#l00022">foot_placement.h:22</a></div></div>
<div class="ttc" id="aclassFootPlacement_html_ae58f1f2ea1c2d690d10f4c7b7b0c67d0"><div class="ttname"><a href="classFootPlacement.html#ae58f1f2ea1c2d690d10f4c7b7b0c67d0">FootPlacement::kp_vx</a></div><div class="ttdeci">double kp_vx</div><div class="ttdoc">Catersian swing foot position control gain in x-axis.</div><div class="ttdef"><b>Definition:</b> <a href="foot__placement_8h_source.html#l00020">foot_placement.h:20</a></div></div>
<div class="ttc" id="aclassFootPlacement_html_a9e1f6a5e58ce202d031a17be6652ce20"><div class="ttname"><a href="classFootPlacement.html#a9e1f6a5e58ce202d031a17be6652ce20">FootPlacement::kp_vy</a></div><div class="ttdeci">double kp_vy</div><div class="ttdoc">Catersian swing foot position control gain in y-axis.</div><div class="ttdef"><b>Definition:</b> <a href="foot__placement_8h_source.html#l00021">foot_placement.h:21</a></div></div>
<div class="ttc" id="aclassFootPlacement_html_a833b5bb6ef5578bfed4d8d50c9786fa7"><div class="ttname"><a href="classFootPlacement.html#a833b5bb6ef5578bfed4d8d50c9786fa7">FootPlacement::dataBusWrite</a></div><div class="ttdeci">void dataBusWrite(DataBus &amp;robotState)</div><div class="ttdoc">Write swing foot information to databus.</div><div class="ttdef"><b>Definition:</b> <a href="foot__placement_8cpp_source.html#l00027">foot_placement.cpp:27</a></div></div>
<div class="ttc" id="aclassFootPlacement_html_ae2211312c822d1d49d61553fbf692feb"><div class="ttname"><a href="classFootPlacement.html#ae2211312c822d1d49d61553fbf692feb">FootPlacement::Trajectory</a></div><div class="ttdeci">double Trajectory(double phase, double des1, double des2)</div><div class="ttdoc">Generate the desired swing leg z-position using Besier curve.</div><div class="ttdef"><b>Definition:</b> <a href="foot__placement_8cpp_source.html#l00066">foot_placement.cpp:66</a></div></div>
<div class="ttc" id="aclassFootPlacement_html_a3aa4e1578da7623da69007b491e8765b"><div class="ttname"><a href="classFootPlacement.html#a3aa4e1578da7623da69007b491e8765b">FootPlacement::tSwing</a></div><div class="ttdeci">double tSwing</div><div class="ttdoc">swing time</div><div class="ttdef"><b>Definition:</b> <a href="foot__placement_8h_source.html#l00026">foot_placement.h:26</a></div></div>
<div class="ttc" id="astructDataBus_html_a0dcb8a4552bb6b37259a61d601cd7d7e"><div class="ttname"><a href="structDataBus.html#a0dcb8a4552bb6b37259a61d601cd7d7e">DataBus::LegState</a></div><div class="ttdeci">LegState</div><div class="ttdoc">enum current leg stance states</div><div class="ttdef"><b>Definition:</b> <a href="data__bus_8h_source.html#l00164">data_bus.h:164</a></div></div>
<div class="ttc" id="aclassFootPlacement_html_a65426884931e20e457a72ebd2885ca91"><div class="ttname"><a href="classFootPlacement.html#a65426884931e20e457a72ebd2885ca91">FootPlacement::desWz_W</a></div><div class="ttdeci">double desWz_W</div><div class="ttdoc">desired angular velocity projected on z-axis</div><div class="ttdef"><b>Definition:</b> <a href="foot__placement_8h_source.html#l00029">foot_placement.h:29</a></div></div>
<div class="ttc" id="aclassFootPlacement_html_a44ed054253f62f43df8b23f60694d600"><div class="ttname"><a href="classFootPlacement.html#a44ed054253f62f43df8b23f60694d600">FootPlacement::getSwingPos</a></div><div class="ttdeci">void getSwingPos()</div><div class="ttdoc">Calculate the desired position of the swing foot.</div><div class="ttdef"><b>Definition:</b> <a href="foot__placement_8cpp_source.html#l00031">foot_placement.cpp:31</a></div></div>
<div class="ttc" id="aclassFootPlacement_html_a8bc8c4f7d3ffc58d244cfc3935e31c13"><div class="ttname"><a href="classFootPlacement.html#a8bc8c4f7d3ffc58d244cfc3935e31c13">FootPlacement::legState</a></div><div class="ttdeci">DataBus::LegState legState</div><div class="ttdoc">record the leg state, used to make swing motion inward</div><div class="ttdef"><b>Definition:</b> <a href="foot__placement_8h_source.html#l00059">foot_placement.h:59</a></div></div>
<div class="ttc" id="aclassFootPlacement_html_ab42c8e066a9f7d1997ca7780af64c932"><div class="ttname"><a href="classFootPlacement.html#ab42c8e066a9f7d1997ca7780af64c932">FootPlacement::stepHeight</a></div><div class="ttdeci">double stepHeight</div><div class="ttdoc">the maximal height of the foot when walking a step</div><div class="ttdef"><b>Definition:</b> <a href="foot__placement_8h_source.html#l00024">foot_placement.h:24</a></div></div>
<div class="ttc" id="aclassFootPlacement_html_a7efde20d6d1358c936a6d97b98993413"><div class="ttname"><a href="classFootPlacement.html#a7efde20d6d1358c936a6d97b98993413">FootPlacement::phi</a></div><div class="ttdeci">double phi</div><div class="ttdoc">phase varialbe for trajectory generation, must between 0 and 1</div><div class="ttdef"><b>Definition:</b> <a href="foot__placement_8h_source.html#l00025">foot_placement.h:25</a></div></div>
<div class="ttc" id="astructDataBus_html"><div class="ttname"><a href="structDataBus.html">DataBus</a></div><div class="ttdoc">The software model for data transporting.</div><div class="ttdef"><b>Definition:</b> <a href="data__bus_8h_source.html#l00022">data_bus.h:22</a></div></div>
<div class="ttc" id="aclassFootPlacement_html_abefe39cf532cd6ee56094fd96b9aead1"><div class="ttname"><a href="classFootPlacement.html#abefe39cf532cd6ee56094fd96b9aead1">FootPlacement::dataBusRead</a></div><div class="ttdeci">void dataBusRead(DataBus &amp;robotState)</div><div class="ttdoc">Read data from databus.</div><div class="ttdef"><b>Definition:</b> <a href="foot__placement_8cpp_source.html#l00011">foot_placement.cpp:11</a></div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>
